package com.qiaoas.springbootmybatisbymysqlcrud.Controller;

import com.qiaoas.springbootmybatisbymysqlcrud.Bean.User;
import com.qiaoas.springbootmybatisbymysqlcrud.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("create")
    public void create()
    {
        User user = new User();
        user.setNo(11);
        user.setAge(18);;
        user.setName("qiaoaaaaaas");
        this.userService.insert(user);
    }
    @RequestMapping("delete")
    public void delete(){
        this.userService.delete(11);
    }

    @RequestMapping("update")
    public void update(String name){
        User user = new User();
        user.setNo(11);
        user.setAge(99);
        user.setName(name);
        this.userService.update(user);
    }

    @RequestMapping("select")
    public User select(){
        return this.userService.userQuery(11);
    }
}
